package com.lcxw.hxzbadmin.dao.adminmapper;

import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;
import com.lcxw.hxzbadmin.entity.pojo.GoodName;

@Mapper
@Component
public interface GoodNameMapper {

    @Delete({
        "delete from ywpd_goodname",
        "where `id` = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id)throws Exception;

    @Insert({
        "insert into ywpd_goodname (`name`, `price`, ",
        "`sold`, `addTime`, `remark`)",
        "values (#{name,jdbcType=VARCHAR}, #{price,jdbcType=INTEGER}, ",
        "#{sold,jdbcType=BIT}, #{addtime,jdbcType=TIMESTAMP}, #{remark,jdbcType=VARCHAR})"
    })
    int insert(GoodName goodName)throws Exception;

    @Select({
        "select",
        "`id`, `name`, `price`, `sold`, `addTime`, `remark`",
        "from ywpd_goodname",
        "where `id` = #{id,jdbcType=INTEGER}"
    })
    GoodName selectByPrimaryKey(Integer id)throws Exception;

    @Select("SELECT * FROM ywpd_goodname WHERE name=#{name}")
    GoodName selectByName(String name)throws Exception;

    @Select("SELECT * FROM ywpd_goodname")
    List<GoodName> selectAll()throws Exception;

    @Update({
        "update ywpd_goodname",
        "set `name` = #{name,jdbcType=VARCHAR},",
        "`price` = #{price,jdbcType=INTEGER},",
        "`sold` = #{sold,jdbcType=BIT},",
        "`addTime` = #{addtime,jdbcType=TIMESTAMP},",
        "`remark` = #{remark,jdbcType=VARCHAR}",
        "where `id` = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(GoodName goodName) throws Exception;


}
